<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Noun Phrases</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Noun Phrases' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../services.html">Services</a></li><li><a href="index.html">linguistics</a></li><li><a href="index.html#4">Chapter 4: Diagramming Sentences</a></li><li><b>Noun Phrases</b></li></ul></div>
<p class="purpose">To construct noun-phrase subtrees for assertion sentences.</p>

<ul class="toc"><li><a href="4-np.html#SP1">&#167;1. Hierarchy of noun phrases</a></li><li><a href="4-np.html#SP2">&#167;2. Raw nounphrases (NP1)</a></li><li><a href="4-np.html#SP5">&#167;5. Articled nounphrases (NP2)</a></li><li><a href="4-np.html#SP8">&#167;8. List-divided nounphrases (NP3)</a></li><li><a href="4-np.html#SP10">&#167;10. Full nounphrases (NP4)</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Hierarchy of noun phrases.</b>Noun phrase nodes are built at four levels of elaboration, which we take in
turn:
</p>

<ul class="items"><ul class="items"><li>(NP1) Raw: where the text is entirely untouched and unannotated.
</li><li>(NP2) Articled: where any initial article is converted to an annotation.
</li><li>(NP3) List-divided: where, in addition, a list is broken up into individual items.
</li><li>(NP4) Full: where, in addition, pronouns, relative phrases establishing
relationships and properties, and so on are parsed.
</li></ul>
</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Raw nounphrases (NP1).</b>A raw noun phrase is always a single <span class="extract"><span class="extract-syntax">UNPARSED_NOUN_NT</span></span>. The following always
matches any non-empty text:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-unparsed&gt;</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>This "balanced" version, however, requires any brackets and braces to be
used in a balanced way: thus <span class="extract"><span class="extract-syntax">frogs ( and toads )</span></span> would match, but
<span class="extract"><span class="extract-syntax">frogs ( and</span></span> would not. It therefore does not always match.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-unparsed-bal&gt;</span>
<span class="plain-syntax">    ^</span><span class="function-syntax">&lt;balanced-text&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-unparsed&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>The noun phrase of an existential sentence is recognised thus:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-existential&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">there</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Articled nounphrases (NP2).</b>Now an initial article becomes an annotation and is removed from the text.
Note that
</p>

<ul class="items"><li>(a) Unexpectedly upper-case articles are left well alone, as in the sentence:
</li></ul>
<blockquote>
    <p>On the table is a thing called A Town Called Alice.</p>
</blockquote>

<ul class="items"><li>(b) Articles are not removed if that would leave the text empty.
</li><li>(c) If we are in a language where the same word might either be definite or
indefinite, the latter has precedence.
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-articled&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;if-not-cap&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;indefinite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-unparsed&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;if-not-cap&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;definite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-unparsed&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-unparsed&gt;</span>

<span class="function-syntax">&lt;np-articled-bal&gt;</span>
<span class="plain-syntax">    ^</span><span class="function-syntax">&lt;balanced-text&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-articled&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="function-syntax">NounPhrases::add_art</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">NounPhrases::add_art</span></span>:<br/><a href="4-np.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="reserved-syntax">article_usage</span><span class="plain-syntax"> *</span><span class="identifier-syntax">au</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Node::set_article</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">au</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>The following function is only occasionally useful; it takes an existing raw
node and retrospectively applies &lt;np-articled&gt; to it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="function-syntax">NounPhrases::annotate_by_articles</span><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">RAW_NP</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-articled&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">RAW_NP</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">MODEL</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Node::set_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">RAW_NP</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">MODEL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Node::set_article</span><span class="plain-syntax">(</span><span class="identifier-syntax">RAW_NP</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_article</span><span class="plain-syntax">(</span><span class="identifier-syntax">MODEL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RAW_NP</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. List-divided nounphrases (NP3).</b>An "articled list" matches text like "the lion, a witch, and some wardrobes"
as a list of articled noun phrases.
</p>

<p class="commentary">Note that the requirement that non-final terms in the list have to be balanced
means that an and or a comma inside brackets can never be a divider. Thus
"the horse (and its boy)" would be one item, not two.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-articled-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-articled-bal&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-articled-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-articled&gt;</span>

<span class="function-syntax">&lt;np-articled-tail&gt;</span>
<span class="plain-syntax">    , {</span><span class="identifier-syntax">_and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-articled-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-articled-list&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>"Alternative lists" divide up at "or" rather than "and", thus matching text
such as "voluminous, middling big or poky", and the individual entries are not
articled.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-alternative-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-unparsed-bal&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-alternative-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-unparsed&gt;</span>

<span class="function-syntax">&lt;np-alternative-tail&gt;</span>
<span class="plain-syntax">    , {</span><span class="identifier-syntax">_or</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-alternative-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">or</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-alternative-list&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. Full nounphrases (NP4).</b>When fully parsing the structure of a nounphrase, we have five different
constructions in play, and need to work out their precedence over each other:
rather as <span class="extract"><span class="extract-syntax">*</span></span> takes precedence over <span class="extract"><span class="extract-syntax">+</span></span> in arithmetic expressions in C, so
here we have &mdash;
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="constant-syntax">RELATIONSHIP_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">CALLED_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">WITH_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">AND_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">KIND_NT</span>
</pre>
<p class="commentary">That is, relative clauses take precedence over callings, and so on. The
above hierarchy is arrived at thus:
</p>

<ul class="items"><li>(a) We need <span class="extract"><span class="extract-syntax">RELATIONSHIP_NT &gt; WITH_NT</span></span> so that "X is in a container with
carrying capacity 10" will work.
</li><li>(b) We need <span class="extract"><span class="extract-syntax">WITH_NT &gt; AND_NT</span></span> so that "X is a container with carrying
capacity 10 and diameter 12" will work.
</li><li>(c) We need <span class="extract"><span class="extract-syntax">CALLED_NT &gt; WITH_NT</span></span> so that "X is a container called the flask
with flange" will work.
</li><li>(d) We need <span class="extract"><span class="extract-syntax">RELATIONSHIP_NT &gt; CALLED_NT</span></span> so that "A man called Horse is in
the High Sierra" will work.
</li><li>(e) We want <span class="extract"><span class="extract-syntax">KIND_NT</span></span> to be of low precedence because it is always either
the word "kind" alone, or "kind of N" for some atomic noun N.
</li></ul>
<p class="commentary">See <a href="P-asd.html" class="internal">About Sentence Diagrams</a> for numerous examples.
</p>

<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>Full nounphrase parsing varies slightly according to the position of the
phrase, i.e., whether it is in the subject or object position. Thus "X is Y"
or "X is in Y" would lead to X being parsed by &lt;np-as-subject&gt;, Y by &lt;np-as-object&gt;.
They are identical except that:
</p>

<ul class="items"><li>(a) In subject position, a full nounphrase can use "there" to indicate
an existential sentence such as "there is a hair in my soup"; and
</li><li>(b) In subject position, a relative phrase cannot begin with a word which
looks like a participle.
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-as-subject&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-existential&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;if-not-cap&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-relative-phrase-limited&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-nonrelative&gt;</span>

<span class="function-syntax">&lt;np-as-object&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;if-not-cap&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-relative-phrase-unlimited&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-nonrelative&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>To explain the limitation here: RPs only exist in the subject position due
to subject-verb inversion in English. Thus, "In the Garden is a tortoise" is a
legal inversion of "A tortoise is in the Garden". Following this logic we ought
to accept Yoda-like inversions such as "Holding the light sabre is the young Jedi",
but we don't want to do that, because then a sentence like "Holding Area is a room"
might have to be read as saying that a nameless room is holding something
called "Area".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-relative-phrase-limited&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-relative-phrase-implicit&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;probable-participle&gt;</span><span class="plain-syntax"> *** |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-relative-phrase-explicit&gt;</span>

<span class="function-syntax">&lt;np-relative-phrase-unlimited&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-relative-phrase-implicit&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-relative-phrase-explicit&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>Inform guesses above that most English words ending in "-ing" are present
participles &mdash; like guessing, bluffing, cheating, and so on. But there is
a conspicuous exception to this; so any word found in &lt;non-participles&gt;
is never treated as a participle.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;non-participles&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">thing</span><span class="plain-syntax">/</span><span class="identifier-syntax">something</span>

<span class="function-syntax">&lt;probable-participle&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Vocabulary::test_flags</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">), </span><span class="identifier-syntax">ING_MC</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;non-participles&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) { ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> }; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>An implicit RP is a word like "carried", or "worn", on its own &mdash; this
implies a relation to some unspecified noun. We represent that in the tree
using the "implied noun" pronoun. For now, these are fixed.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-relative-phrase-implicit&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">worn</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">carried</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">initially</span><span class="plain-syntax"> </span><span class="identifier-syntax">carried</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14_1" class="paragraph-anchor"></a><b>&#167;14.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on the implicit RP worn</span><span class="named-paragraph-number">14.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">production</span><span class="plain-syntax"> }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><a href="1-dgr.html#SP7" class="function-link"><span class="function-syntax">Diagrams::new_implied_RELATIONSHIP</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">R_wearing</span><span class="plain-syntax">) }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-np.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_2" class="paragraph-anchor"></a><b>&#167;14.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on the implicit RP carried</span><span class="named-paragraph-number">14.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">production</span><span class="plain-syntax"> }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><a href="1-dgr.html#SP7" class="function-link"><span class="function-syntax">Diagrams::new_implied_RELATIONSHIP</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">R_carrying</span><span class="plain-syntax">) }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-np.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_3" class="paragraph-anchor"></a><b>&#167;14.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Act on the implicit RP initially carried</span><span class="named-paragraph-number">14.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">production</span><span class="plain-syntax"> }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF_MODULE</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><a href="1-dgr.html#SP7" class="function-link"><span class="function-syntax">Diagrams::new_implied_RELATIONSHIP</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">R_carrying</span><span class="plain-syntax">) }</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-np.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>An explicit RP is one which uses a preposition and then a noun phrase: for
example, "on the table" is explicit.
</p>

<p class="commentary">Note that we throw out a relative phrase if the noun phrase within it would
begin with "and" or a comma; this enables us to parse sentences concerning
directions, in particular, a little better. But it means we do not recognise
"of, by and for the people" as an RP.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-relative-phrase-explicit&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;permitted-preposition&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;permitted-preposition&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;permitted-preposition&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-nonrelative&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15_1" class="paragraph-anchor"></a><b>&#167;15.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Work out a meaning</span><span class="named-paragraph-number">15.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="constant-syntax">VERB_MEANING_LINGUISTICS_TYPE</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R</span><span class="plain-syntax"> = </span><a href="3-vm.html#SP9" class="function-link"><span class="function-syntax">VerbMeanings::get_regular_meaning_of_form</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><a href="3-vrb.html#SP11" class="function-link"><span class="function-syntax">Verbs::find_form</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">permitted_verb</span><span class="plain-syntax">, </span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    ==&gt; { -, </span><a href="1-dgr.html#SP7" class="function-link"><span class="function-syntax">Diagrams::new_RELATIONSHIP</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><a href="3-vm.html#SP2" class="function-link"><span class="function-syntax">VerbMeanings::reverse_VMT</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">), </span><span class="identifier-syntax">RP</span><span class="plain-syntax">[2]) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-np.html#SP15">&#167;15</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>We have now disposed of <span class="extract"><span class="extract-syntax">RELATIONSHIP_NT</span></span> and are left with the constructs:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="constant-syntax">CALLED_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">WITH_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">AND_NT</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">KIND_NT</span>
</pre>
<p class="commentary">These are all handled by &lt;np-nonrelative&gt;. Two points to note:
</p>

<ul class="items"><li>(a) The first production accepts arbitrary text quickly and without allocating
memory if we're in lookahead mode &mdash; an important economy since otherwise
parsing a list of \(n\) items would have running time and memory of order \(2^n\).
</li><li>(b) If we regard the above constructs as being like operators in arithmetic,
then the operands have to match &lt;np-operand&gt;, and this requires text which has
balanced brackets. That ensures that, for example, "frog (called toad)"
is not misread as saying that "frog (" is called "toad )". But note that
the final &lt;np-articled&gt; production catches any unbalanced text, so even
text like "smile X-)" will in fact match &lt;np-nonrelative&gt;.
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-nonrelative&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-operand&gt;</span><span class="plain-syntax"> {</span><span class="identifier-syntax">called</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-articled-bal&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-operand&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-with-or-having-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-operand&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-and-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-kind-phrase&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;agent-pronoun&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;here-pronoun&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-articled&gt;</span>

<span class="function-syntax">&lt;np-operand&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;if-not-cap&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-relative-phrase-unlimited&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    ^</span><span class="function-syntax">&lt;balanced-text&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-nonrelative&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>The tail of with-or-having parses for instance "with carrying capacity 5"
in the NP
</p>

<blockquote>
    <p>a container with carrying capacity 5</p>
</blockquote>

<p class="commentary">This makes use of a nifty feature of Preform: when Preform scans to see how to
divide the text, it tries &lt;np-with-or-having-tail&gt; in each possible position.
The reply can be yes, no, or no and move on a little. So if we spot "it with
action", the answer is no, and move on three words: that jumps over a "with"
which we don't want to recognise. (Because if we did, then "the locking it
with action" would be parsed as a property list, "action", attaching to a
bogus object called "locking it".)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-with-or-having-tail&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">it</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax"> *** |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">with</span><span class="plain-syntax">/</span><span class="identifier-syntax">having</span><span class="plain-syntax">} (/) *** |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">with</span><span class="plain-syntax">/</span><span class="identifier-syntax">having</span><span class="plain-syntax">} ... ( </span><span class="function-syntax">&lt;response-letter&gt;</span><span class="plain-syntax"> ) |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">with</span><span class="plain-syntax">/</span><span class="identifier-syntax">having</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-new-property-list&gt;</span>

<span class="function-syntax">&lt;np-new-property-list&gt;</span>
<span class="plain-syntax">    ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-new-property&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-new-property-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-new-property&gt;</span>

<span class="function-syntax">&lt;np-new-property-tail&gt;</span>
<span class="plain-syntax">    , {</span><span class="identifier-syntax">_and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-new-property-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-new-property-list&gt;</span>

<span class="function-syntax">&lt;np-new-property&gt;</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>The "and" tail is much easier:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-and-tail&gt;</span>
<span class="plain-syntax">    , {</span><span class="identifier-syntax">_and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-operand&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">and</span><span class="plain-syntax">} </span><span class="function-syntax">&lt;np-operand&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>Kind phrases are easier:
</p>

<blockquote>
    <p>A sedan chair is a kind of vehicle. A weather pattern is a kind.</p>
</blockquote>

<p class="commentary">Note that indefinite articles are permitted before the word "kind(s)",
but definite articles are not.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;np-kind-phrase&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;indefinite-article&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-kind-phrase-unarticled&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;np-kind-phrase-unarticled&gt;</span>

<span class="function-syntax">&lt;np-kind-phrase-unarticled&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax">/</span><span class="identifier-syntax">kinds</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax">/</span><span class="identifier-syntax">kinds</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;np-operand&gt;</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="3-apoo.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-lm.html">1</a></li><li class="progresschapter"><a href="2-adj.html">2</a></li><li class="progresschapter"><a href="3-vrb.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresscurrent">np</li><li class="progresssection"><a href="4-vp.html">vp</a></li><li class="progressnext"><a href="4-vp.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

